package org.DownLoad;

import org.come.log.LanderJPanel;

public class DownloadStart {
    public static void downloadstart(String UrlName,String save_path,String save_name){
       // String game2="http://127.0.0.1:8088/GameServer/update/"+"v1.6"+".zip";
        //1、连接服务器，获取一个文件，获取文件的长度，在本地创建一个大小跟服务器文件一样大的临时文件
        ThreadDownload threadDownload = new ThreadDownload(UrlName, save_path,save_name);
        //设置线程数
        threadDownload.setThreadCount(15);
        //开启断点下载
        threadDownload.setBpDownload(true);
        //添加进度和网速监听
        threadDownload.addSpeedListener(new SpeedListener() {
            @Override
            public void speed(int s, double progress) {
                String m=String.format("%.1f",(double) s/1024/1024);
                String pro=String.format("%.1f",progress);
                LanderJPanel.getVersion2().setText(m+"m/s--进度："+pro+"%");
                //System.out.println(m+"m/s--进度："+pro+"%");
            }

        });
        //由于ThreadDownload类也是个线程类，可以开启线程
        System.out.println("开启下载");
        threadDownload.run();
        
    }
}
